unit UModule_Entry_Mapel_Soal;

interface

uses
  Dialogs,
  Controls,
  SysUtils,
  Classes,
  InvokeRegistry,
  Rio,
  XSBuiltIns,
  SOAPHTTPClient,
  ActnList,
  soap_sis_entry_mapel_soal;

type
  TModule_Entry_Mapel_Soal = class(TDataModule)
    HTTPRIO1: THTTPRIO;
    ActionList1: TActionList;
    PFile_Simpan: TAction;
    PMenu_Entry_MapelSoal: TAction;
    PCommon_Daftar_Subject: TAction;
    procedure PFile_SimpanExecute(Sender: TObject);
    procedure PMenu_Entry_MapelSoalExecute(Sender: TObject);
    procedure HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
    procedure PCommon_Daftar_SubjectExecute(Sender: TObject);
  private
    FDataMapel: TDataMapel;
    procedure Assign_LoginInfo;
  public
    procedure Assign_Action;
  end;

var
  Module_Entry_Mapel_Soal: TModule_Entry_Mapel_Soal;

implementation

uses
  UMainApplication,
  UUser;
{$R *.dfm}

procedure TModule_Entry_Mapel_Soal.Assign_Action;
begin
try
  with Form_Main do
    begin
    TMB0105010601070201.Action := PFile_Simpan;
    TMB01050106010701.Action   := PCommon_Daftar_Subject;
    with CB010501 do
      begin
      with Categories[5] do
        begin
        Items[3].Action := PMenu_Entry_MapelSoal;
        end;
      end;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Mapel_Soal.Assign_LoginInfo;
begin
try
  with Form_Main do
    begin
    GServer_Host     := IN010301.Text;
    GServer_Database := IN010302.Text;
    GServer_UserName := IN010303.Text;
    GServer_Password := IN010304.Text;
    GUserName        := LE01010101.Text;
    GUserPassword    := LE01010102.Text;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Mapel_Soal.HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
var
  LocalStrings: TStringList;
begin
try
  LocalStrings          := TStringList.Create;
  SOAPResponse.Position := 0;
  LocalStrings.LoadFromStream(SOAPResponse);
  // ShowMessage(LocalStrings.Text);
  FreeAndNil(LocalStrings);
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Mapel_Soal.PCommon_Daftar_SubjectExecute(Sender: TObject);
var
  InfoServer: TInfoServer;
  LocalIndex: word;
  localCount: Integer;
begin
try
  with HTTPRIO1 as SERVICE_ENTRY_SISWA_MAPELSOALPortType do
    begin
    Assign_LoginInfo;
    InfoServer                 := TInfoServer.Create;
    InfoServer.Server_Host     := GServer_Host;
    InfoServer.Server_Database := GServer_Database;
    InfoServer.Server_Username := GServer_UserName;
    InfoServer.Server_Password := GServer_Password;
    DATA_MAPEL(InfoServer, FDataMapel);
    localCount := high(FDataMapel);
    if localCount > 0 then
      begin
      with Form_Main do
        begin
        with IN01050106010701, Items do
          begin
          BeginUpdate;
          Clear;
          for LocalIndex := 0 to high(FDataMapel) do
            begin
            with FDataMapel[LocalIndex] do
              begin
              Add(MAPEL_KODE + ' - ' + MAPEL_NAMA);
              end;
            end;
          EndUpdate;
          ItemIndex := 0;
          end;
        end;
      end;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Mapel_Soal.PFile_SimpanExecute(Sender: TObject);
var
  InfoServer:            TInfoServer;
  DataMapelSoalInputRow: TDataMapelSoalInputRow;
  DataMapelSoalInput:    TDataMapelSoalInput;
begin
try
  Assign_LoginInfo;
  InfoServer                 := TInfoServer.Create;
  DataMapelSoalInputRow      := TDataMapelSoalInputRow.Create;
  InfoServer.Server_Host     := GServer_Host;
  InfoServer.Server_Database := GServer_Database;
  InfoServer.Server_Username := GServer_UserName;
  InfoServer.Server_Password := GServer_Password;
  with Form_Main, HTTPRIO1 as SERVICE_ENTRY_SISWA_MAPELSOALPortType do
    begin
    DataMapelSoalInputRow.MAPEL_ID             := FDataMapel[IN01050106010701.ItemIndex].ID;
    DataMapelSoalInputRow.MAPELSOAL_KODE       := IN01050106010702.Text;
    DataMapelSoalInputRow.MAPELSOAL_JENIS      := IN01050106010703.Text;
    DataMapelSoalInputRow.MAPELSOAL_KELAS      := IN01050106010704.Text;
    DataMapelSoalInputRow.MAPELSOAL_WAKTU      := StrToInt(IN01050106010705.Text);
    DataMapelSoalInputRow.MAPELSOAL_PERTANYAAN := IN01050106010706.Text;
    DataMapelSoalInputRow.MAPELSOAL_JAWABAN    := IN01050106010707.Text;
    DataMapelSoalInputRow.MAPELSOAL_PILIHAN_A  := IN01050106010708.Text;
    DataMapelSoalInputRow.MAPELSOAL_PILIHAN_B  := IN01050106010709.Text;
    DataMapelSoalInputRow.MAPELSOAL_PILIHAN_C  := IN01050106010710.Text;
    DataMapelSoalInputRow.MAPELSOAL_PILIHAN_D  := IN01050106010711.Text;
    DataMapelSoalInputRow.MAPELSOAL_PILIHAN_E  := IN01050106010712.Text;
    DataMapelSoalInputRow.MAPELSOAL_URL_GAMBAR := IN01050106010713.Text;
    DataMapelSoalInputRow.MAPELSOAL_KETERANGAN := IN01050106010714.Text;
    SetLength(DataMapelSoalInput, 1);
    DataMapelSoalInput[0] := DataMapelSoalInputRow;
    SISWA_SIMPAN_MAPELSOAL_DATASET(InfoServer, DataMapelSoalInput);
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Mapel_Soal.PMenu_Entry_MapelSoalExecute(Sender: TObject);
begin
try
  with Form_Main, TAB010501060107 do
    begin
    Show;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

end.
